建立商品頁面控制器
public ActionResult Index(int Page = 1)
{
ItemView Data = new ItemView();
Data.Paging = new ForPaging(Page);
Data.IdList = itemService.GetIdList(Data.Paging);
Data.ItemBlock = new List<ItemDetailView>();
foreach (var Id in Data.IdList)
{
ItemDetailView newBlock = new ItemDetailView();
newBlock.Data = itemService.GetDataById(Id);
string Cart = (HttpContext.Session["Cart"] != null)
? HttpContext.Session["Cart"].ToString() : null;
newBlock.InCart = cartService.CheckInCart(Cart, Id);
Data.ItemBlock.Add(newBlock);
}
return View(Data);
}
public ActionResult Item(int Id)
{
ItemDetailView ViewData = new ItemDetailView();
ViewData.Data = itemService.GetDataById(Id);
string Cart = (HttpContext.Session["Cart"] != null)
? HttpContext.Session["Cart"].ToString() : null;
ViewData.InCart = cartService.CheckInCart(Cart, Id);
return View(ViewData);
}